/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.bean;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Zully
 */
@Entity
@Table(name = "despinches")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Despinches.findAll", query = "SELECT d FROM Despinches d"),
    @NamedQuery(name = "Despinches.findById", query = "SELECT d FROM Despinches d WHERE d.id = :id"),
    @NamedQuery(name = "Despinches.findByFecha", query = "SELECT d FROM Despinches d WHERE d.fecha = :fecha"),
    @NamedQuery(name = "Despinches.findByKmVehiculo", query = "SELECT d FROM Despinches d WHERE d.kmVehiculo = :kmVehiculo"),
    @NamedQuery(name = "Despinches.findByFechaInsercionActualizacion", query = "SELECT d FROM Despinches d WHERE d.fechaInsercionActualizacion = :fechaInsercionActualizacion")})
public class Despinches implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "km_vehiculo")
    private long kmVehiculo;
    @Basic(optional = false)
    @Column(name = "fecha_insercion_actualizacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaInsercionActualizacion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDespinches", fetch = FetchType.LAZY)
    private List<DetalleDespinche> detalleDespincheList;
    @JoinColumn(name = "id_usuarios", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Usuarios idUsuarios;
    @JoinColumn(name = "id_pilotos", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Pilotos idPilotos;
    @JoinColumn(name = "id_neumaticos", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Neumaticos idNeumaticos;

    public Despinches() {
    }

    public Despinches(Long id) {
        this.id = id;
    }

    public Despinches(Long id, Date fecha, long kmVehiculo, Date fechaInsercionActualizacion) {
        this.id = id;
        this.fecha = fecha;
        this.kmVehiculo = kmVehiculo;
        this.fechaInsercionActualizacion = fechaInsercionActualizacion;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public long getKmVehiculo() {
        return kmVehiculo;
    }

    public void setKmVehiculo(long kmVehiculo) {
        this.kmVehiculo = kmVehiculo;
    }

    public Date getFechaInsercionActualizacion() {
        return fechaInsercionActualizacion;
    }

    public void setFechaInsercionActualizacion(Date fechaInsercionActualizacion) {
        this.fechaInsercionActualizacion = fechaInsercionActualizacion;
    }

    @XmlTransient
    public List<DetalleDespinche> getDetalleDespincheList() {
        return detalleDespincheList;
    }

    public void setDetalleDespincheList(List<DetalleDespinche> detalleDespincheList) {
        this.detalleDespincheList = detalleDespincheList;
    }

    public Usuarios getIdUsuarios() {
        return idUsuarios;
    }

    public void setIdUsuarios(Usuarios idUsuarios) {
        this.idUsuarios = idUsuarios;
    }

    public Pilotos getIdPilotos() {
        return idPilotos;
    }

    public void setIdPilotos(Pilotos idPilotos) {
        this.idPilotos = idPilotos;
    }

    public Neumaticos getIdNeumaticos() {
        return idNeumaticos;
    }

    public void setIdNeumaticos(Neumaticos idNeumaticos) {
        this.idNeumaticos = idNeumaticos;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Despinches)) {
            return false;
        }
        Despinches other = (Despinches) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.camachosanchez.bean.Despinches[ id=" + id + " ]";
    }
    
}
